Skip to content

TASK-055: emit CEG shadow comparison outputs - #178

Merged
cryptoxdog merged 1 commit into
mainfrom
l9/w8/task-055
Aug 2, 2026
Merged

TASK-055: emit CEG shadow comparison outputs#178
cryptoxdog merged 1 commit into
mainfrom
l9/w8/task-055

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Generated under L9 controlled autonomy.

Task: TASK-055
Program: sha256:9cd1a79f948dac419913c134396e58359e4df82862bb3901bdd327684a37cb52
Contract: sha256:514d282ce3d47c1c0d2b0167d6bb77d21904b2f789e1d5996e0cd0e8d65d457f
Verification: sha256:58ac85f9a17dc29122f19c26726122af0629dd5dc340c62996e31faa2bc773ff

This PR is draft only. The controller cannot mark ready, approve, merge, tag, release, or deploy.

Copilot AI review requested due to automatic review settings August 2, 2026 19:35
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

⚠️ Large PR Warning
Reviewable lines changed: 319
Warning threshold: 300 lines
Consider splitting for easier review

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Exclude it from reviewable-size accounting

This PR passes the blocking limit but is larger than recommended.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

L9 Audit Harness Report

  • Generated: 2026-08-02T19:35:54.312773+00:00
  • Repo root: /home/runner/work/Cognitive.Engine.Graphs/Cognitive.Engine.Graphs
  • Overall result: ✅ PASSED
  • Exit code: 0

Step Results

Step Status Exit Code Notes
Architecture Audit ✅ Passed 0
Spec Coverage ✅ Passed 0
Contract Wiring ✅ Passed 0

Architecture Audit Findings

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 25
🔵 LOW 0

See artifacts/audit_report.md for full details.

Spec Coverage

  • ✅ Implemented: 37
  • ⚠️ Partial: 9
  • ❌ Missing: 0
  • Total features: 46
Category Implemented Partial Missing Total
gates 10 0 0 10
scoring 7 0 0 7
v1.1_node 2 0 0 2
v1.1_edge 2 0 0 2
v1.1_action 0 2 0 2
v1.1_scoring 1 1 0 2
action_handler 0 6 0 6
gds_algorithm 5 0 0 5
research_pattern 10 0 0 10

See artifacts/coverage_report.md for full details.

Next Steps

All checks passed. Safe to merge.

@cryptoxdog
cryptoxdog marked this pull request as ready for review August 2, 2026 19:36
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@cryptoxdog
cryptoxdog merged commit 660e21f into main Aug 2, 2026
42 of 49 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an observational-only “shadow comparison” artifact for CEG, enabling deterministic JSON output that compares primary vs shadow candidate rankings without affecting production match authority.

Changes:

  • Added engine/shadow/ comparison types + comparison function that emits mismatch classes (rank, score, missing, extra) and a deterministic checksum.
  • Added tools/shadow_comparison.py CLI to generate the comparison artifact from an offline JSON input.
  • Added unit tests plus supporting runbook + ADR for TASK-055.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
engine/shadow/compare.py Implements ranking normalization, mismatch detection, and deterministic serialization/checksum.
engine/shadow/init.py Exposes the shadow comparison API via package exports.
tools/shadow_comparison.py CLI wrapper to load rankings from JSON and emit a comparison artifact JSON file.
tests/unit/test_shadow_comparison.py Unit coverage for checksum determinism, mismatch classes, and CLI artifact writing.
docs/runbooks/CEG_SHADOW_COMPARISON.md Operational runbook for offline emission and safety/rollback guidance.
docs/adr/ADR-110-ceg-shadow-comparison-outputs.md ADR documenting the decision and constraints for shadow comparison outputs.

Comment thread engine/shadow/compare.py
@@ -0,0 +1,136 @@
"""Deterministic primary-vs-shadow ranking comparison (observational only)."""
Comment on lines +38 to +47
data = json.loads(Path(args.input).read_text())
comparison = emit_shadow_comparison(
packet_id=str(data["packet_id"]),
primary=_load_ranked(data.get("primary") or []),
shadow=_load_ranked(data.get("shadow") or []),
)
out = Path(args.output)
out.parent.mkdir(parents=True, exist_ok=True)
payload = comparison.to_dict()
out.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n")
Comment thread engine/shadow/__init__.py
Comment on lines +1 to +4
"""Observational shadow comparison outputs (TASK-055).

Does not replace primary match authority.
"""
Comment thread engine/shadow/compare.py
Comment on lines +31 to +55
@dataclass
class ShadowComparison:
schema: str = "l9.ceg.shadow_comparison.v1"
packet_id: str = ""
observational: bool = True
replaces_primary: bool = False
primary: list[RankedCandidate] = field(default_factory=list)
shadow: list[RankedCandidate] = field(default_factory=list)
mismatches: list[Mismatch] = field(default_factory=list)
checksum: str = ""

def to_dict(self) -> dict[str, Any]:
body = {
"schema": self.schema,
"packet_id": self.packet_id,
"observational": self.observational,
"replaces_primary": self.replaces_primary,
"primary": [asdict(x) for x in self.primary],
"shadow": [asdict(x) for x in self.shadow],
"mismatches": [asdict(x) for x in self.mismatches],
}
blob = json.dumps(body, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
self.checksum = "sha256:" + hashlib.sha256(blob.encode()).hexdigest()
body["checksum"] = self.checksum
return body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants